<%--
  Created by IntelliJ IDEA.
  User: 骆鹏
  Date: 2017/7/27
  Time: 11:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%--<%@ include file="/WEB-INF/app/header.jsp" %>--%>


<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>入党积极分子</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="/lib/layui/layui/css/eleTree.css?2019101815.40">
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/eleTree.css">
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/layui/layui/layui.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <style>
        .locality-p{
            height: 40px;
            /*background: #3791DA;*/
            /*color: #fff;*/
            font-size: 18px;
            line-height: 40px;
            /*border-bottom:1px solid #9E9E9E;*/
            display: inline-block;
            padding:0 10px;
            margin: 10px;
            /*border-radius: 10px;*/
            /*border-right: 1px solid;*/
        }
        .content{
            height: 100%;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<%--<div class="headTop" style="margin-top: 20px;border-bottom: 1px solid #999;">--%>
<%--    <div class="headImg" style="margin-bottom: 5px;">--%>
<%--&lt;%&ndash;        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/icon_task.png" alt="" style="margin-left: 20px">&ndash;%&gt;--%>
<%--        <span style="font-size: 18px; margin-left: 30px">所有入党积极分子</span>--%>
<%--    </div>--%>
<%--</div>--%>

<div class="container">
    <div class="header">
        <p class="locality-p"><img src="/img/commonTheme/theme6/wangluo.png" style="margin-right: 5px"></img>入党积极分子</p>
    </div>

    <div class="content">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div style="padding: 0px 8px">
                        <table id="demo" lay-filter="test"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="doSth">
    <a class="layui-btn layui-btn-xs" lay-event="look" id="look">查看</a>
</script>

<script type="text/html" id="toolbar">
<div class="layui-form-item" style="margin-bottom: 0px">
    <div class="layui-inline" style="margin-bottom: 0px;">
        <label class="layui-form-label" style="width: 150px">选择党支部</label>
        <div class="layui-input-inline">
            <select name="modules" id="pertain" lay-verify="required" lay-search=""class="layui-select options">
                <option value="">直接选择或搜索选择</option>
            </select>
        </div>
    </div>
    <a class="layui-btn layui-btn-sm searchbtn" data-type="reload" style="height: 30px;line-height: 30px">搜索</a>
    <a href="/partyMember/getFileExport?phase=2"type="button" class="layui-btn immp layui-btn-sm " style="margin-right: 15px" >
        <i class="layui-icon">&#xe601;</i>
        导出
    </a>
</div>
</script>

<script>
    layui.use(['form','table','laypage'], function(){
        var table = layui.table;
        var form = layui.form;
        var laypage = layui.laypage;
        var sele;
        table.render({
            elem: '#demo'
            , url:'/partyMember/selectByPhase?phase=2'
            , page:true
            ,type: 'get'
            ,toolbar:'#toolbar'
            ,cols: [[
               {field:'userName',title:'姓名',align:'center'}
                ,
                {
                    field: 'sex', title: '性别', align: 'center',templet: function(d){
                        if(d.sex=='0'){
                            return  d.sex = '男'
                        }else{
                            return d.sex = '女'
                        }
                    }}
                , {field: 'parentPedtName', title: '所属部门', align: 'center'}
                ,{title: '操作', align: 'center', toolbar: '#doSth', width: 300,}
            ]]
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.totleNum, //解析数据长度
                    "data": res.obj, //解析数据列表
                };
            }
        });

        table.on('tool(test)', function (obj) {
            var data= obj.data
            if(obj.event === 'look'){
                // window.location.href="/bbs/theme?boardId="+data.boardId+'&isCheck='+data.needCheck;
                window.location.href="/partyMember/activistLook?userId="+data.userId;
            }
        })


        //自定义每页条数的选择项
        // laypage.render({
        //     elem: 'demo'
        //     ,count: 1000
        //     ,limit: 100
        //     ,limits: [100, 300, 500]
        // })
        // 详情点击事件
        $('.contentBody').on('click', '.detail_a', function () {
            var userId = $(this).attr("userId");
            window.location.href="/partyMember/activistLook?userId="+userId;
        });

        $.ajax({
            url: '/orgDepartment/selectSum',
            dataType: 'json',
            type: 'get',
            success: function (res) {
                var object = res.obj
                var str = ''
                for (var i = 0; i < object.length; i++) {
                    if(object[i].orgDeptParent==0){
                        str += '<option style="text-align: left" value="' + object[i].orgDeptId + '">' + object[i].orgDeptName + '</option>'
                        var parent = object[i];
                        var count = "";
                        str += alone(object,parent,count);
                    }
                }
                $('#pertain').append(str)
                form.render('select');
            }
        })

        function alone(ob,parent,count){
            var str = '';
            count +="--";
            for(var i=0;i<ob.length;i++){
                if(ob[i].orgDeptParent == parent.orgDeptId){
                    str += '<option style="text-align: left" value="' + ob[i].orgDeptId + '">|'+count + ob[i].orgDeptName + '</option>'
                    str += alone(ob,ob[i],count);
                }


            }
            return str;
        }


        // 搜索功能
        $(document).on('click','.searchbtn',function () { //重载表格
            sele =  $('.options').val()
            if(sele==""){
                table.render({
                    elem: '#demo'
                    , url:'/partyMember/selectByPhase?phase=2'
                    , page:true
                    ,type: 'get'
                    ,toolbar:'#toolbar'
                    ,cols: [[
                        {field:'userName',title:'姓名',align:'center'}
                        ,
                        {
                            field: 'sex', title: '性别', align: 'center',templet: function(d){
                                if(d.sex=='0'){
                                    return  d.sex = '男'
                                }else{
                                    return d.sex = '女'
                                }
                            }}
                        , {field: 'parentPedtName', title: '所属部门', align: 'center'}
                        ,{title: '操作', align: 'center', toolbar: '#doSth', width: 300,}
                    ]]
                    ,parseData: function(res){ //res 即为原始返回的数据
                        return {
                            "code": 0, //解析接口状态
                            "msg": res.msg, //解析提示文本
                            "count": res.totleNum, //解析数据长度
                            "data": res.obj, //解析数据列表
                        };
                    }
                });
                $.ajax({
                    url: '/orgDepartment/selectSum',
                    dataType: 'json',
                    type: 'get',
                    success: function (res) {
                        var object = res.obj
                        var str = ''
                        for (var i = 0; i < object.length; i++) {
                            if(object[i].orgDeptParent==0){
                                str += '<option style="text-align: left" value="' + object[i].orgDeptId + '">' + object[i].orgDeptName + '</option>'
                                var parent = object[i];
                                var count = "";
                                str += alone(object,parent,count);
                            }
                        }
                        $('#pertain').append(str)
                        form.render('select');
                    }
                })
            }else {
                table.render({
                    elem: '#demo'
                    , url:'/partyMember/getPartyMemberList'
                    ,where:{
                        parentPedtId:sele,
                        phase1:"2",
                        phase2:"",
                    }
                    , page:true
                    ,type: 'get'
                    ,toolbar:'#toolbar'
                    ,cols: [[
                        {field:'userName',title:'姓名',align:'center'}
                        ,
                        {
                            field: 'sex', title: '性别', align: 'center',templet: function(d){
                                if(d.sex=='0'){
                                    return  d.sex = '男'
                                }else{
                                    return d.sex = '女'
                                }
                            }}
                        , {field: 'parentPedtName', title: '所属部门', align: 'center'}
                        ,{title: '操作', align: 'center', toolbar: '#doSth', width: 300,}
                    ]]
                    ,parseData: function(res){ //res 即为原始返回的数据
                        return {
                            "code": 0, //解析接口状态
                            "msg": res.msg, //解析提示文本
                            "count": res.totleNum, //解析数据长度
                            "data": res.obj, //解析数据列表
                        };
                    }
                });
                $.ajax({
                    url: '/orgDepartment/selectSum',
                    dataType: 'json',
                    type: 'get',
                    success: function (res) {
                        var object = res.obj
                        var str = ''
                        for (var i = 0; i < object.length; i++) {
                            if(object[i].orgDeptParent==0){
                                str += '<option style="text-align: left" value="' + object[i].orgDeptId + '">' + object[i].orgDeptName + '</option>'
                                var parent = object[i];
                                var count = "";
                                str += alone(object,parent,count);
                            }
                        }
                        $('#pertain').append(str)
                        form.render('select');
                    }
                })
            }
        })
    });
</script>
</body>
</html>
